package com.ethink.platform.controller.warehouse;

import com.ethink.warehouse.api.info.MateInventoryOrderMoreInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.warehouse.api.MateInventoryOrderFacade;
import com.ethink.warehouse.api.info.MateInventoryOrderInfo;
import com.ethink.warehouse.api.request.MateInventoryOrderAddRequest;
import com.ethink.warehouse.api.request.MateInventoryOrderQueryRequest;
import com.ethink.warehouse.api.request.MateInventoryOrderUpdateRequest;

/**
 * 入库/出库单 Controller
 *
 * @author default
 * @date 2022-12-15
 */
@Tag(name = "MateInventoryOrderController", description = "入库/出库单 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/warehouse-service")
public class MateInventoryOrderController extends BaseController {

    @Autowired
    private MateInventoryOrderFacade mateInventoryOrderFacade;

    @Operation(summary = "分页查询")
    @GetMapping("/mateInventoryOrder/query")
    public CommonResponse<List<MateInventoryOrderMoreInfo>> queryMateInventoryOrder(MateInventoryOrderQueryRequest request) {
        return succeedWithPage(mateInventoryOrderFacade.queryMateInventoryOrder(request));
    }

    @Operation(summary = "详情查询")
    @GetMapping("/mateInventoryOrder/get/{mateInventoryOrderId}")
    public CommonResponse<MateInventoryOrderInfo> getMateInventoryOrderById(@PathVariable("mateInventoryOrderId") Long mateInventoryOrderId) {
        return succeedWith(mateInventoryOrderFacade.getMateInventoryOrderById(mateInventoryOrderId));
    }

    @Operation(summary = "查询所有")
    @GetMapping("/mateInventoryOrder/list")
    public CommonResponse<List<MateInventoryOrderMoreInfo>> listMateInventoryOrder(MateInventoryOrderQueryRequest request) {
        return succeedWith(mateInventoryOrderFacade.listMateInventoryOrder(request));
    }

    @Operation(summary = "新增")
    @PostMapping("/mateInventoryOrder/add")
    public CommonResponse addMateInventoryOrder(@RequestBody MateInventoryOrderAddRequest request) {
        mateInventoryOrderFacade.addMateInventoryOrder(request);
        return succeed();
    }

    @Operation(summary = "更新")
    @PutMapping("/mateInventoryOrder/update")
    public CommonResponse updateMateInventoryOrder(@RequestBody MateInventoryOrderUpdateRequest request) {
        mateInventoryOrderFacade.updateMateInventoryOrder(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/mateInventoryOrder/delete/{mateInventoryOrderId}")
    public CommonResponse deleteMateInventoryOrder(@PathVariable("mateInventoryOrderId") Long mateInventoryOrderId) {
        mateInventoryOrderFacade.deleteMateInventoryOrder(mateInventoryOrderId);
        return succeed();
    }

}